#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
//猜数字游戏
void game()
{
	int guess = 0;
	int r = rand() % 100 + 1;
	system("cls");
	while (1)
	{
		printf("请输入你猜的数字：\n");
		scanf("%d", &guess);
		if (guess < r)
		{
			printf("猜小了，继续加油\n");
		}
		else if (guess > r)
		{
			printf("猜大了，要继续努力\n");
		}
		else
		{
			printf("恭喜你猜对了，正确答案就是%d，你真棒！\n", r);
			break;
		}


	}


}
int main()
{
	int input = 0;
	srand((unsigned int)time(NULL));
	do
	{
		printf("*********************\n");
		printf("**** 1.play game ****\n");
		printf("**** 2.over game ****\n");
		printf("*********************\n");
		printf("请输入你的选择:");
		scanf("%d", &input);
		switch (input)
		{
		case 1:
			game();
			break;
		case 2:
			printf("游戏结束，下次再来玩\n");
			break;
		default:
			printf("输错了，再输一次\n");
			break;

		}

	} while (input);
    return 0;
}
